﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ImportMediaAction.cs" company="Prolific Notion">
//   (c) Copyright 2010 Simon Dingley t/a Prolific Notion, http://prolificnotion.co.uk
// </copyright>
// <summary>
//   Defines the ImportMediaAction type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

#region License
// --------------------------------------------------------------------------------------------------------------------
// Distrbuted under the MIT License
// --------------------------------------------------------------------------------------------------------------------

// (c) Copyright 2010 Simon Dingley t/a Prolific Notion, http://prolificnotion.co.uk

// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all copies or substantial portions of 
// the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// --------------------------------------------------------------------------------------------------------------------
#endregion

namespace ProlificNotion.Umbraco.ImportMedia
{
    using System;

    using global::umbraco.interfaces;

    /// <summary>
    /// Defines the ImportMediaAction type.
    /// </summary>
    public class ImportMediaAction : IAction
    {
        /// <summary>
        /// Create a singleton
        /// </summary>
        private static readonly ImportMediaAction instance = new ImportMediaAction();

        /// <summary>Prevents a default instance of the <see cref="ImportMediaAction"/> class from being created. 
        /// Initializes a new instance of the <see cref="ImportMediaAction"/> class.</summary>
        private ImportMediaAction()
        {
        }

        /// <summary>
        /// Gets the instance.
        /// </summary>
        /// <value>The instance.</value>
        public static ImportMediaAction Instance
        {
            get { return instance; }
        }

        #region IAction Members

        /// <summary>
        /// Gets the unique letter assigned to this IAction implementation
        /// </summary>
        public char Letter
        {
            get { return 'þ'; }
        }

        /// <summary>
        /// Gets a value indicating whether [show in notifier].
        /// </summary>
        /// <value><c>true</c> if [show in notifier]; otherwise, <c>false</c>.</value>
        public bool ShowInNotifier
        {
            get { return true; }
        }

        /// <summary>
        /// Gets a value indicating whether the menu item can be permission assignable. 
        /// If set to false, the menu item will show up for all users.
        /// </summary>
        public bool CanBePermissionAssigned
        {
            get { return false; }
        }

        /// <summary>
        /// Gets the icon used to display this IAction in the UI.
        /// </summary>
        /// <value>The icon to display.</value>
        public string Icon
            {
                get { return "images/umbraco/drive_go.png"; }
        }

        /// <summary>
        /// Gets the alias.
        /// </summary>
        /// <value>The alias.</value>
        public string Alias
        {
            get { return "Import Media from Server"; }
        }

        /// <summary>
        /// Gets a path to a JavaScript file that contains the custom JavaScript to call.
        /// </summary>
        public string JsSource
        {
            get { return String.Empty; }
        }

        /// <summary>
        /// Gets the method to call in the custom JavaScript file. The JavaScript file will 
        /// be rendered out in the parent frame
        /// so the call to the method needs to be prefixed with "parent." Since the JavaScript 
        /// file is rendered out in the parent frame
        /// the script will have access to the properties of the umbracoDefault.js script    
        /// which contains properties such as nodeID (which is
        /// the id of the node that is use has right clicked).
        /// </summary>
        public string JsFunctionName
        {
            get { return "openModal('dialogs/ImportMedia.aspx?id=' + nodeID, 'Import Media', 450, 550);"; }
        }

        #endregion
    }
}
